/*
 * Copyright (C) 2007-2008 SlideMe client
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.slideme.android.manager.media;

import org.kxml2.io.KXmlParser;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Meta {

    private String infoURL;

    private String installParam;

    private String description;

    private String downloadNotifyURI;

    private String installNotifyURI;

    private List<License> license;

    private List<String> text;

    private String name;

    private String deleteNotifyURI;

    private Environment environment;

    private String suppressUserConfirmation;

    private String media;


    public static Meta marshalFrom(KXmlParser parser) throws IOException {
        if (parser == null) {
            throw new IllegalArgumentException("parser");
        }
        Meta meta = new Meta();
        try {
            parser.require(XmlPullParser.START_TAG, null, "meta");
            while (parser.nextTag() == XmlPullParser.START_TAG) {
                String tagName = parser.getName();
                if (tagName.equals("name")) {
                    meta.setName(parser.nextText());
                } else if (tagName.equals("media")) {
                    meta.setMedia(parser.nextText());
                } else if (tagName.equals("infoURL")) {
                    meta.setInfoURL(parser.nextText());
                } else if (tagName.equals("deleteNotifyURI")) {
                    meta.setDeleteNotifyURI(parser.nextText());
                } else if (tagName.equals("description")) {
                    meta.setDescription(parser.nextText());
                } else if (tagName.equals("downloadNotifyURI")) {
                    meta.setDownloadNotifyURI(parser.nextText());
                } else if (tagName.equals("installNotifyURI")) {
                    meta.setInstallNotifyURI(parser.nextText());
                } else if (tagName.equals("installParam")) {
                    meta.setInstallParam(parser.nextText());
                } else if (tagName.equals("suppressUserConfirmation")) {
                    meta.setSuppressUserConfirmation(parser.nextText());
                }

            }
        } catch (XmlPullParserException e) {
            throw new IOException("JV-000-010:" + e.toString());
        }
        return meta;
    }

    public Meta() {
        license = new ArrayList<License>();
        text = new ArrayList<String>();
    }

    public String getInfoURL() {
        return infoURL;
    }

    public void setInfoURL(String infoURL) {
        this.infoURL = infoURL;
    }

    public String getInstallParam() {
        return installParam;
    }

    public void setInstallParam(String installParam) {
        this.installParam = installParam;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDownloadNotifyURI() {
        return downloadNotifyURI;
    }

    public void setDownloadNotifyURI(String downloadNotifyURI) {
        this.downloadNotifyURI = downloadNotifyURI;
    }

    public String getInstallNotifyURI() {
        return installNotifyURI;
    }

    public void setInstallNotifyURI(String installNotifyURI) {
        this.installNotifyURI = installNotifyURI;
    }

    public List<License> getLicense() {
        return license;
    }

    public void setlicense(List<License> license) {
        this.license = license;
    }

    public List<String> getText() {
        return text;
    }

    public void setText(List<String> text) {
        this.text = text;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDeleteNotifyURI() {
        return deleteNotifyURI;
    }

    public void setDeleteNotifyURI(String deleteNotifyURI) {
        this.deleteNotifyURI = deleteNotifyURI;
    }

    public Environment getEnvironment() {
        return environment;
    }

    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }

    public String getSuppressUserConfirmation() {
        return suppressUserConfirmation;
    }

    public void setSuppressUserConfirmation(String suppressUserConfirmation) {
        this.suppressUserConfirmation = suppressUserConfirmation;
    }

    public String getMedia() {
        return media;
    }

    public void setMedia(String media) {
        this.media = media;
    }
}
